#include<cstdio>
#include<cstring>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=210;
int n,a[MAXN],pre[MAXN],f[MAXN][MAXN],g[MAXN][MAXN],h[MAXN][MAXN];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i+n]=a[i]=read();
		pre[i]=pre[i-1]+a[i];
		h[i][i]=i;
	}
	for(int i=n+1;i<=(n<<1);++i)
	{
		pre[i]=pre[i-1]+a[i];
		h[i][i]=i;
	}
	for(int len=2;len<=n;++len)
		for(int i=1,j;(j=i+len-1)<=(n<<1);++i)
		{
			g[i][j]=max(g[i][j-1],g[i+1][j])+pre[j]-pre[i-1];
			f[i][j]=INF;
			for(int k=h[i][j-1];k<=h[i+1][j];++k)
				if(f[i][j]>f[i][k]+f[k+1][j]+pre[j]-pre[i-1])
				{
					f[i][j]=f[i][k]+f[k+1][j]+pre[j]-pre[i-1];
					h[i][j]=k;
				}
		}
	int ans1=INF,ans2=0;
	for(int i=1;i<=n;++i)
	{
		ans1=min(ans1,f[i][i+n-1]);
		ans2=max(ans2,g[i][i+n-1]);
	}
	printf("%d\n%d\n",ans1,ans2);
	return 0;
}
